package fatboy.test;

import java.io.IOException;
import java.net.UnknownHostException;

public class Phase3AutoDistributedDriver {
	private static String[] remoteComps = {"algea","pineapple","knife"};
	public static void main(String[] args){
		String pass = args[0];
		Runtime frame = java.lang.Runtime.getRuntime();
		String computer = "";
		try {
			computer = java.net.InetAddress.getLocalHost().getHostName();
			//System.out.println(idNumber);
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		//call driver to start on this machine
		final int port = 4444;
		try {
			frame.exec("java -cp ../.. fatboy.communication.Phase3Driver " + port);
			frame.exec("java -cp ../.. fatboy.communication.Phase3Driver "+ computer +" " + port);
			for(String comp : remoteComps){
				frame.exec("ssh " + comp);
				frame.exec("java -cp ../.. fatboy.communication.Phase3Driver "+ computer +" " + port);
				frame.exec("java -cp ../.. fatboy.communication.Phase3Driver "+ computer +" " + port);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
